package com.project.service.sys;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.project.service.BaseService;
import com.project.dao.sys.SysLogDao;
import com.project.entity.sys.SysLog;
import com.project.util.CurrentSessionUtil;

/**
 *  系统日志service
 * @author 
 *
 */
@Transactional
@Service
public class SysLogService extends BaseService<SysLog>{

	@Autowired
	private SysLogDao sysLogDao;
	
	
	/**
	 * 根据ID获取SysLog
	 * @param id
	 * @return
	 */
	public SysLog getSysLogDao(Long id){
		return sysLogDao.getById(id);
	}

	
	/**
	 * 新建日志
	 * @param role
	 */
	public void save(SysLog sysLog){
		sysLog.setCreateUser(CurrentSessionUtil.getCurrentUser().getUserCode());
		sysLog.setCreateTime(new Date());
		sysLogDao.saveOrUpdate(sysLog);
	}
	
	public void save(String logType, String tableModel, Long pkId, String module, String content,
			String rmk){
		SysLog sysLog=new SysLog(logType, tableModel, pkId, module, 
				content, rmk, CurrentSessionUtil.getCurrentUser().getUserCode(), new Date());
		sysLogDao.saveOrUpdate(sysLog);
	}
	public void saveByQuartz(String logType, String tableModel, Long pkId, String module, String content,
			String rmk){
		SysLog sysLog=new SysLog(logType, tableModel, pkId, module, 
				content, rmk,null, new Date());
		sysLogDao.saveOrUpdate(sysLog);
	}

}
